<template>
    <div>
      <div class="store-main">
        <div class="account-top-left">
          <el-input v-model="search" style="width: 300px;" placeholder="请输店铺名或店主名">
            <el-button slot="append"  icon="el-icon-search" @click.prevent="getListUserInfo(pageUserInfo.size,1)"></el-button>
          </el-input>
        </div>
        <el-table
          :data="pageStoreData.records"
          style="width: 100%">
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item label="店铺名称">
                  <span>{{ props.row.storename }}</span>
                </el-form-item>
                <el-form-item label="店主">
                  <span>{{ props.row.linkman }}</span>
                </el-form-item>

                <el-form-item label="联系电话">
                  <span>{{ props.row.phone }}</span>
                </el-form-item>

                <el-form-item label="店铺地址">
                  <span>{{ props.row.address }}</span>
                </el-form-item>
                <el-form-item label="餐饮许可证">
                  <el-image
                    style="width: 100px; height: 100px"
                    :src="props.row.permit"
                    :preview-src-list="[props.row.permit]">
                  </el-image>
                </el-form-item>
                <el-form-item label="营业执照">
                  <el-image
                    style="width: 100px; height: 100px"
                    :src="props.row.license"
                    :preview-src-list="[props.row.license]">
                  </el-image>
                </el-form-item>
                <el-form-item label="营业时间">
                  <span>{{ props.row.dhptime }}</span>
                </el-form-item>



              </el-form>
            </template>
          </el-table-column>
          <el-table-column
            label="商铺ID"
            prop="id">
          </el-table-column>
          <el-table-column
            label="商铺名称"
            prop="storename">
          </el-table-column>
          <el-table-column
            label="商铺图标"
            prop="logo">
            <template slot-scope="scope" >
              <el-image
                style="width: 100px; height: 50px"
                :src="scope.row.logo"
                fit="contain"></el-image>
            </template>
          </el-table-column>
          <el-table-column
            label="店主"
            prop="linkman">
          </el-table-column>
          <el-table-column
            label="商铺评分"
            prop="storescore">
          </el-table-column>
          <el-table-column
            label="商铺状态"
            prop="storestatus">
            <template slot-scope="scope" >
              <span v-text="scope.row.storestatus==0?'待审批':scope.row.storestatus==1?'营业':scope.row.storestatus==2?'歇业':scope.row.storestatus==3?'审批未通过':'禁用'"></span>
            </template>
          </el-table-column>

          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="primary"
                size="mini"
                :disabled="scope.row.storestatus==4?false:true"
                @click="enableBtn(scope.row.id)"
                >启用</el-button>
              <el-button
                size="mini"
                type="danger"
                :disabled="scope.row.storestatus==2||scope.row.storestatus==1?false:true"
                @click="disableBtn(scope.row.id)"
              >禁用</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageStoreData.current"
          :page-sizes="[6, 8, 10, 12]"
          :page-size="6"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageStoreData.total">
        </el-pagination>
      </div>
    </div>
</template>

<script>
    export default {
        name: "StoreManger",
        data(){
          return {
            search:"",
            pageStoreData:{
            //   total:10,
            //   current:1,
            //   size:6,
            //   records:[
            //     {
            //       id:1,
            //       storename:"胖娃烧烤",
            //       linkman:"胖娃",
            //       logo:"http://localhost/static/img/img02.9246251.png",
            //       phone:"13372602740",
            //       address:"重庆",
            //       dhptime:"10:00-20:30",
            //       license:"http://localhost/static/img/img-temp06.png",
            //       permit:"http://localhost/static/img/img-temp06.png",
            //       storescore:"4.0",
            //       storestatus:"1"
            //     },
            //     {
            //       id:1,
            //       storename:"胖娃烧烤",
            //       linkman:"胖娃",
            //       logo:"http://localhost/static/img/img02.9246251.png",
            //       phone:"13372602740",
            //       address:"重庆",
            //       dhptime:"10:00-20:30",
            //       license:"http://localhost/static/img/img-temp06.png",
            //       permit:"http://localhost/static/img/img-temp06.png",
            //       storescore:"4.0",
            //       storestatus:"1"
            //     },
            //     {
            //       id:1,
            //       storename:"胖娃烧烤",
            //       linkman:"胖娃",
            //       logo:"http://localhost/static/img/img02.9246251.png",
            //       phone:"13372602740",
            //       address:"重庆",
            //       dhptime:"10:00-20:30",
            //       license:"http://localhost/static/img/img-temp06.png",
            //       permit:"http://localhost/static/img/img-temp06.png",
            //       storescore:"4.0",
            //       storestatus:"1"
            //     }
            //   ]
            }
          }
        },
        methods:{
          enableBtn(id){
            this.$http.get("/storeInfo/enableStore/"+id).then(resp=>{
              if(resp.data.code==200) {
                this.$message({
                  showClose: true,
                  message: resp.data.message,
                  type: 'success'
                });
              }
            });
          },
          disableBtn(id){
            this.$http.get("/storeInfo/disableStore/"+id).then(resp=>{
              if(resp.data.code==200) {
                this.$message({
                  showClose: true,
                  message: resp.data.message,
                  type: 'success'
                });
              }
            });
          },
          handleSizeChange(val){
            this.getStoreData(this.pageStoreData.current,val);
          },
          handleCurrentChange(val) {
            this.getStoreData(val,this.pageStoreData.size)
          },
          getStoreData(pageNum,pageSize){
            this.$http.get("/storeInfo/getStoreManger",{
              params:{
                pageNum:pageNum,
                pageSize:pageSize,
                search:this.search
              }
            }).then(resp=>{
              this.pageStoreData=resp.data.data;
            })
          }
        },
        created() {
          this.getStoreData(1,6);
        }
    }
</script>

<style scoped>
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0px;
    margin-bottom: 0;
    width: 50%;
  }
</style>
